home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Sapphire Collection / Software Vault (Sapphire Collection) (Digital Impact).ISO / cdr08 / finst152.zip / INSTALLR.H_ / INSTALLR.H
C/C++ Source or Header  |  1994-07-30  |  8KB  |  205 lines

  1. #define __INSTALLR_H
  2.  
  3. #ifndef __TIMER_H
  4. #include "timer.h"
  5. #endif
  6. #ifndef __STDLIB_H
  7. #include "stdlib.h"
  8. #endif
  9. #ifndef __WINDOWS_H
  10. #include "windows.h"
  11. #endif
  12.  
  13.  
  14. struct version                                       /* version info of a file */
  15. {
  16.    UINT lang;                                                   /* language id */
  17.    UINT cset;                                                 /* character set */
  18.    DWORD os;                                                             /* os */
  19.    DWORD prmtype;                              /* primary type (exe, dll, etc) */
  20.    DWORD subtype;                         /* sub type (display, keyboard, etc) */
  21.    DWORD verhi32;                                     /* high 32bit version no */
  22.    DWORD verlo32;                                      /* low 32bit version no */
  23. };
  24.  
  25. class copymonitor                                              /* copy monitor */
  26. {
  27.    public:
  28.  
  29.    virtual int getblksize()             = 0;
  30.    virtual int notify(LONG nobytesread) = 0;
  31. };
  32.  
  33. class voidcopymonitor:public copymonitor    /* copy monitor which does nothing */
  34. {
  35.    public:
  36.  
  37.    int getblksize()
  38.    {
  39.       return 0; /* return 0 means copy the whole file, no blocking is required */
  40.    }
  41.    int notify(LONG nobytesread)
  42.    {
  43.       return 1;                                              /* always succeed */
  44.    }
  45. };
  46.  
  47. class pmconv;
  48. class oprdr;
  49. class voidrdr;
  50. class simpledde;
  51. struct pmiteminfo;
  52.  
  53. class installer                        /* name space for installation routines */
  54. {
  55.    int isrunpm;                    /* did we start PM in order to DDE with it? */
  56.    int issupressmsg;                         /* should error msg be supressed? */
  57.    char dirw[_MAX_PATH];                                        /* Windows dir */
  58.    char diry[_MAX_PATH];                                 /* Windows system dir */
  59.    char dirs[_MAX_PATH];                                 /* install source dir */
  60.    HWND owner;                                             /* owner of dialogs */
  61.    HWND msgdlg;                                                 /* message dlg */
  62.    HWND oldowner;               /* original owner of dialogs before the msgdlg */
  63.    oprdr *rdr;            /* recorder to record all operations (for uninstall) */
  64.    pmconv *c;                             /* conversation with program manager */
  65.    FARPROC p;                            /* procedure instance the message dlg */
  66.    simpledde *d;                                                /* dde wrapper */
  67.    HINSTANCE inst;
  68.  
  69.    public:
  70.    installer();                                           /* set bufs to empty */
  71.   ~installer();                                                    /* del bufs */
  72.  
  73.    char *getdirw()             { return dirw;     }
  74.    char *getdiry()             { return diry;     }
  75.    char *getdirs()             { return dirs;     }
  76.    HWND getowner()             { return owner;    }
  77.    HWND getmsgdlg()            { return msgdlg;   } 
  78.  
  79.    static voidrdr vrdr;                     /* a op recorder that does nothing */
  80.  
  81.    static voidcopymonitor vcm;             /* a copy monitor that does nothing */
  82.  
  83.    int copy(int srch, int dsth, copymonitor &cm);
  84.    int copy(char srcpath[], char dstpath[], int ischkver = 0, int isshared = 0, int iscompressed = 0, copymonitor &cm = vcm);
  85.    int deldir(char dir[]);
  86.    int multideldir(char dir[]);
  87.    int delfile(char dir[], char file[]);
  88.    int delfile(char path[]);
  89.    int renfile(char path[]);
  90.    int renfile(char oldpath[], char newpath[]);
  91.    int setfileattrib(char path[], UINT newflags);
  92.    int delinisect(char file[], char sect[]);
  93.    int addinisect(char file[], char sect[]);
  94.    int insinientry(char file[], char sect[], char entry[], char value[], int seqno = 0);
  95.    int addinientry(char file[], char sect[], char entry[], char value[]);
  96.    int delinientry(char file[], char sect[], char entry[], int seqno = 0);
  97.    int setinivalue(char file[], char sect[], char entry[], char value[], int seqno = 0);
  98.    int askdir(char dir[], char prompt[]);
  99.    int askquitinstall();
  100.    int askquitllatsni();
  101.    int askretry(char msg[]);
  102.    int askdrive(int *driveno, char prompt[]);
  103.    int askinsertdisk(char diskdesc[]);
  104.    int askoverwrite(char srcpath[], version &srcv, char dstpath[], version &dstv);
  105.    int msgbox(char txt[], char title[], UINT flags);
  106.    int msgbox(char txt[], char title[], HICON icon, char *buttontxts[]);
  107.    int msgbox(char txt[], char title[], char icon[], char *buttontxts[]);
  108.    int begddepm();
  109.    int runpm();
  110.    int endpm();
  111.    int execwait(char path[], int showcmd);
  112.    int getversion(char path[], version *v);
  113.    int addgrup(char grup[]);
  114.    int delgrup(char grup[]);
  115.    int additem(char grup[], char item[], char cmdl[], char icon[], int iidx = 0);
  116.    int additem(char grup[], pmiteminfo &pmii);
  117.    int delitem(char grup[], char item[]);
  118.    int getfreespace(int drive, double *f);
  119.    int chkfreespace(int drive, double minf);
  120.    int chkdiroccupied(char dir[]);
  121.    int chkgrupoccupied(char grup[]);
  122.    int chkexistdir(char path[]);
  123.    int chkexistdrive(char path[]);
  124.    int compareversion(char srcpath[], char dstpath[]);
  125.    int mkdir(char dir[]);
  126.    int multimkdir(char dir[]);
  127.    int forceexist(char diskdesc[], char path[]);
  128.    int setsupressmsg(int b);
  129.    int setregkey(char kpath[], char value[]);
  130.    int addregkey(char kpath[]);
  131.    int delregkey(char kpath[]);
  132.    int getregkey(char kpath[], char value[]);
  133.    int getnosubkeys(char kpath[]);
  134.    int chkexistregkey(char kpath[]);
  135.    int chkregkeyoccupied(char kpath[]);
  136.    int assertinddepm();
  137.    void init(HINSTANCE inst, HWND owner);
  138.    void attachrdr(oprdr &rdr);
  139.    void begmsgdlg(char txt[], char title[]);
  140.    void endmsgdlg();
  141.    void peekdispatchmsg();
  142.    void endddepm(int isendpm);
  143.    void mergedf(char path[], char d[], char f[]);
  144.    void getdfrompath(char path[], char d[]);
  145.    void getffrompath(char path[], char f[]);
  146.    void outofmem();
  147.    void error(char msg[], ...);
  148.    void errordel(char path[]);
  149.    void errorren(char oldpath[], char newpath[]);
  150.    void errorread(char path[]);
  151.    void errorcopy(char srcpath[], char dstpath[]);
  152.    void errorexec(char name[]);
  153.    void errormkdir(char dir[]);
  154.    void errorwrite(char path[]);
  155.    void errorshare(char path[]);
  156.    void errorcreate(char path[]);
  157.    void erroraccess(char path[]);
  158.    void errornofile(char path[]);
  159.    void errorbadpath(char path[]);
  160.    void errordelitem(char name[]);
  161.    void errordelgrup(char name[]);
  162.    void erroradditem(char name[]);
  163.    void erroraddgrup(char name[]);
  164.    void errorshowgrup(char name[]);
  165.    void errorfileinuse(char path[]);
  166.    void erroropenregkey(char path[]);
  167.    void errorreadverinfo();
  168.    void changingcolor(HDC dc, RECT r1, RECT r2, COLORREF cs[], int blkw, int blkh);
  169.    LONG getfilesize(char path[]);
  170.    HWND findpmmainwnd();
  171.    HWND setowner(HWND owner);
  172.    oprdr &detachrdr();
  173. };
  174.  
  175. class pmddekeeper
  176. {
  177.    int isendpm;
  178.    installer &ir;
  179.  
  180.    public:
  181.    pmddekeeper(int *r, installer &irx, int isendpmx):ir(irx)
  182.    {
  183.       isendpm = isendpmx;
  184.  
  185.       *r = ir.begddepm();                                         /* begin DDE */
  186.    }
  187.   ~pmddekeeper()
  188.    {
  189.       ir.endddepm(isendpm);
  190.    }
  191. };
  192.  
  193. class msgdlgkeeper
  194. {
  195.    timer tm;
  196.    installer &ir;
  197.  
  198.    public:
  199.    msgdlgkeeper(installer &ir, char msg[], char title[], DWORD deltime);
  200.   ~msgdlgkeeper();
  201.  
  202.    void peekdispatchmsg();
  203. };
  204.  
  205.